namespace IdentityExample.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class addAuditRecords : DbMigration
    {
        public override void Up()
        {
            AddColumn("dbo.Movies", "CreatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.Movies", "UpdatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.Movies", "CreatedDate", c => c.DateTime(nullable: false));
            AddColumn("dbo.Movies", "UpdatedDate", c => c.DateTime(nullable: false));
            AddColumn("dbo.Ratings", "CreatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.Ratings", "UpdatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.Ratings", "CreatedDate", c => c.DateTime(nullable: false));
            AddColumn("dbo.Ratings", "UpdatedDate", c => c.DateTime(nullable: false));
            AddColumn("dbo.UserMovies", "CreatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.UserMovies", "UpdatedByUserId", c => c.String(nullable: false, maxLength: 128));
            AddColumn("dbo.UserMovies", "CreatedDate", c => c.DateTime(nullable: false));
            AddColumn("dbo.UserMovies", "UpdatedDate", c => c.DateTime(nullable: false));
            CreateIndex("dbo.Movies", "CreatedByUserId");
            CreateIndex("dbo.Movies", "UpdatedByUserId");
            CreateIndex("dbo.Ratings", "CreatedByUserId");
            CreateIndex("dbo.Ratings", "UpdatedByUserId");
            CreateIndex("dbo.UserMovies", "CreatedByUserId");
            CreateIndex("dbo.UserMovies", "UpdatedByUserId");
            AddForeignKey("dbo.Movies", "CreatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
            AddForeignKey("dbo.Movies", "UpdatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
            AddForeignKey("dbo.Ratings", "CreatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
            AddForeignKey("dbo.Ratings", "UpdatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
            AddForeignKey("dbo.UserMovies", "CreatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
            AddForeignKey("dbo.UserMovies", "UpdatedByUserId", "dbo.AspNetUsers", "Id", cascadeDelete: false);
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.UserMovies", "UpdatedByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.UserMovies", "CreatedByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.Ratings", "UpdatedByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.Ratings", "CreatedByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.Movies", "UpdatedByUserId", "dbo.AspNetUsers");
            DropForeignKey("dbo.Movies", "CreatedByUserId", "dbo.AspNetUsers");
            DropIndex("dbo.UserMovies", new[] { "UpdatedByUserId" });
            DropIndex("dbo.UserMovies", new[] { "CreatedByUserId" });
            DropIndex("dbo.Ratings", new[] { "UpdatedByUserId" });
            DropIndex("dbo.Ratings", new[] { "CreatedByUserId" });
            DropIndex("dbo.Movies", new[] { "UpdatedByUserId" });
            DropIndex("dbo.Movies", new[] { "CreatedByUserId" });
            DropColumn("dbo.UserMovies", "UpdatedDate");
            DropColumn("dbo.UserMovies", "CreatedDate");
            DropColumn("dbo.UserMovies", "UpdatedByUserId");
            DropColumn("dbo.UserMovies", "CreatedByUserId");
            DropColumn("dbo.Ratings", "UpdatedDate");
            DropColumn("dbo.Ratings", "CreatedDate");
            DropColumn("dbo.Ratings", "UpdatedByUserId");
            DropColumn("dbo.Ratings", "CreatedByUserId");
            DropColumn("dbo.Movies", "UpdatedDate");
            DropColumn("dbo.Movies", "CreatedDate");
            DropColumn("dbo.Movies", "UpdatedByUserId");
            DropColumn("dbo.Movies", "CreatedByUserId");
        }
    }
}
